<template>
    <div id="main">
 <el-container>
            <el-header>
                <span>餐饮商城管理系统</span>
            </el-header>
        <el-container>
            <el-aside>
                <el-scrollbar>
                <el-menu :default-active="activeIndex" :router="true" class="el-menu-demo" mode="vertical" @select="handleSelect">
                    <el-menu-item index="1" @click="doStoreInfo">门店基本信息</el-menu-item>
                    <el-menu-item index="2" @click="aa">菜品操作</el-menu-item>
                    <el-menu-item index="3" @click="bb">订单操作</el-menu-item>
                    <el-menu-item index="4" @click="cc">菜类操作</el-menu-item>
                    <el-menu-item index="5" @click="dd">餐桌操作</el-menu-item>
                    </el-menu>
                </el-scrollbar>       
            </el-aside>
        <el-container>
            <el-main>
              <el-form ref="form" label-width="80px">
                <el-form-item label="选择门店">
                  <el-select v-model="storeForm.storeId" placeholder="请选择门店"  @change="setStoreId" >
                    <el-option v-for="store in stores" :label="store.storeName" :value="store.storeId" :key="store.storeId" ></el-option>
                  </el-select>
                </el-form-item>
                
              </el-form>
                <router-view/>
                
            </el-main>
            <el-footer></el-footer>
            </el-container>
            </el-container>
        </el-container>
        



    </div>
</template>

<script>
import dish from '../views/DishView.vue'
export default {
    data() {
      return {
        activeIndex: '1',
        storeForm:{
          storeId:'',
        },
        stores:[],
        storeaa:{},
        storeInfo:{},
      }
    },
    components:{
      dish,
    },
    mounted(){
      
      if(localStorage.getItem("auth")!=null){
        console.log(localStorage.getItem("auth"));
        //  token = localStorage.getItem("userId");
        this.$axios.get("http://localhost:8082/getStore",
              {
                params:{

                }
              }).then(response =>{
                    console.log(response);
                    if(response.data.code!='200'){
                      this.$message.error(response.data.message);
                    }else{
                      this.stores = response.data.data;
                      console.log(this.stores)
                    }
                  })
      }else{
        this.$message.error("请先登录");
      }
      
    },
    methods: {
        handleSelect(key, keyPath) {
        console.log(key, keyPath);
      },
      doStoreInfo(){
        this.$router.push("/storeInfo");
      },
      aa(){
        this.$router.push("/dish");
        console.log()
        // console.log(localStorage.getItem("jwt"));
      },
      bb(){
        this.$router.push("/orderback");
      },
      cc(){
        this.$router.push("/dishtype");
      },
      dd(){
        this.$router.push("/desk");
      },
      setStoreId(){
        console.log(this.storeForm.storeId);
         localStorage.setItem("storeId",this.storeForm.storeId);
        
      }
    }
  }
</script>